import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * GRAFilter is file filter for GRASP files which use ".gra" extension
 *
 * @version 1.0
 * @author P.Jaya Krishna
 */
class GRAFilter extends FileFilter
{
	/**
	 * Returns true for all directories and GRASP files(.gra).
	 */
	public boolean accept(File f)
	{
		if (f.isDirectory())
			return true;
			
		String extension = null;
		String s = f.getName();
		int i = s.lastIndexOf('.');
		
		if (i > 0 &&  i < s.length() - 1)
			extension = s.substring(i+1).toLowerCase();
			
		if (extension != null)
			if (extension.equals("gra"))
				return true;
			else
				return false;
				
		// returns false if a file does not have extention gra
		return false;
	}
	
	/**
	 * Returns the description of the filter as a string.
	 */
	public String getDescription()
	{
		return "GRASP Files (*.gra)";
	}
}